Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(js): batch DOM updates #372

Merged
merged 2 commits into from
Nov 16, 2020
Merged

feat(js): batch DOM updates #372

merged 2 commits into from
Nov 16, 2020

Conversation

francoischalifour
Copy link
Member

This batches state changes to limit DOM mutations.

Every time we call a setter in autocomplete-core (e.g., in onInput with setSelectedItemId, setQuery, setCollection, etc.), the core onStateChange function is called. We don't need to be notified of all these state changes to render.

As an example:

  • without debouncing: "iphone case" query → 85 renders
  • with debouncing: "iphone case" query → 12 renders

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 14, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit c4f110d:

Sandbox Source
@algolia/js-example Configuration

Copy link
Contributor

@eunjae-lee eunjae-lee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes!

@francoischalifour francoischalifour merged commit d06873e into next Nov 16, 2020
@francoischalifour francoischalifour deleted the feat/js-batch-updates branch November 16, 2020 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants